package com.zhn.evsi.interceptor;

import com.zhn.evsi.common.Result;
import com.zhn.evsi.exception.CustomException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionAdvice {

    public static Logger logger = LoggerFactory.getLogger(ExceptionAdvice.class);

    @ResponseBody
    @ExceptionHandler(CustomException.class)
    public Result handleException(CustomException e){
        logger.error("api异常", e);
        return Result.error(e.getMessage());
    }
}
